<template>
  <div class="mr-root">
    <form action="" id="text">
      <textarea v-model="rep.content" id="" cols="30" rows="1"></textarea>
      <button @submite.prevent @click="newr">评论</button>
    </form>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        rep: {
          content: "",
          accesstoken: "",
          reply_id: ""
        }
      }
    },
    methods: {
      newr() {
        this.axios.post('http://www.vue-js.com/api/v1/topic/'+this.rep.reply_id+'/replies', this.rep)
            .then(data=>{
                console.log(data)
                location.reload()
            })
            .catch(err=>{
                console.log(err)
            })
      }
    },
    created() {

      this.rep.reply_id = this.$route.params.countentid
      console.log( this.$route.params.countentid)
      this.rep.accesstoken = localStorage.getItem("accesstoken")
    }

  }

</script>
<style scoped>
  #text {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
  }
  
  textarea {
    display: inline-block;
    vertical-align: middle;
    outline: none;
    resize: none;
    width: 90%;
    height: 40px;
    border-radius: 20px;
    padding: 5px 15px;
    font-size: .4rem;
  }
  
  form {
    background-color: #666;
  }
  
  button {
    outline: none;
    border: none;
    display: inline-block;
    vertical-align: middle;
    background-color: #4f9639;
    color: white;
    padding: 3px 5px;
    border-radius: 10px;
  }

</style>
